#!/bin/sh
#
# initCluster.sh
#

if [ $# != 5 ];then
  echo "Usage: initCluster.sh configFile controllerIp gtmIp nodeIp username"
  exit 1;
fi

configFile=$1
controllerIp=$2
gtmIp=$3
nodeIp=$4
username=$5

echo su $username -c "ssh $username@$controllerIp \" cd pgxc_ctl; ./clusterInit.sh $configFile $controllerIp $gtmIp $nodeIp\""
su $username -c "ssh $username@$controllerIp \" cd pgxc_ctl; ./clusterInit.sh $configFile $controllerIp $gtmIp $nodeIp\""
	
result=$?

if [ $result -ne 0 ]; then
	exit $result
fi

exit 0
